<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>获取DOM节点值</title>
    <style>
        h3 {
            margin-top: 0;
            color: #4caf50;
        }
        .login {
            width: 300px;
            padding: 32px;
            box-shadow: 2px 2px 10px rgba(0, 0, 0, .1);
            position: fixed;
            top: 40%;
            left: 50%;
            transform: translate(-50%, -50%);
        }
        .form-item {
            display: flex;
            margin-bottom: 16px;
            border-bottom: 1px solid #ccc;
        }
        .form-item .title {
            width: 70px;
            color: #666;
            font-size: 14px;
        }
        .form-item .content {flex: 1;}
        .form-item .content input {
            width: 100%;
            border: 0 none;
            padding: 2px 8px;
            outline: none;
            font-size: 16px;
        }
        .login-btn {
            width: 100%;
            border: 0 none;
            background-color: #4caf50;
            color: white;
            margin-top: 16px;
            outline: none;
            height: 32px;}
        .login-btn:active {background-color: #22ddff;}
    </style>
</head>
<body>
    <form name="login-form" class="login">
        <h3>登入</h3>
        <label class="form-item">
            <div class="title">用户名</div>
            <div class="content">
                <input id="account" class="account" name="account" type="text">
            </div>
        </label>

        <label class="form-item">
            <div class="title">密码</div>
            <div class="content">
                <input name="pwd" type="password">
            </div>
        </label>

        <div>
            <button class="login-btn" type="submit">登入</button>
        </div>
    </form>

    <script>
        var account1 = document.getElementById('account');
        var account2 = document.getElementsByName('account');
        var account3 = document.getElementsByClassName('account');

        alert(account1 === account2[0]);
        alert(account1 === account3[0]);

        var account4 = document.forms['login-form']['account'];

        alert(account1 === account4);

        console.log(document.forms['login-form'].elements);
    </script>
</body>
</html>